/**
 * 
 */
package net.optix;

import android.R.bool;
import android.R.integer;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;

/**
 * @author 姜志光
 * 
 */
public class BasicActivity extends Activity {

	public static final int ADD_ID = Menu.FIRST;

	public static final int DELETE_ID = Menu.FIRST + 1;

	public static final int EXIT_ID = Menu.FIRST + 2;

	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		setContentView(R.layout.main);
	}

	public boolean onCreateOptionsMenu(Menu menu) {

		super.onCreateOptionsMenu(menu);
		
//		Menu subMenu	=	menu.
		Log.v("menu result", "add menu");
		menu.add(0, ADD_ID, 0, "添加");
		menu.add(0, DELETE_ID, 0, "删除");
		menu.add(0, EXIT_ID, 0, "离开");
		
		menu.add(1,ADD_ID+1,0,"group");
		menu.add(1,ADD_ID+2,2,"group 123");
		
		SubMenu subMenu	=	menu.addSubMenu("user");
		subMenu.add("Edit Personal Information");
		subMenu.add("Change Password");
		return true;
	}

	public boolean onOptionsItemSelected(MenuItem menuItem) {

		switch (menuItem.getItemId()) {
		case ADD_ID:
			setTitle("insert ... ");
			break;
		case DELETE_ID:
			setTitle("delete ...");
			break;
		case EXIT_ID:
			finish();
		default:
			break;
		}
		return super.onOptionsItemSelected(menuItem);
	}
}
